const filterStatus = (data) => {
  let state = ''
  switch (data) {
    case true:
      state = `<span><i class='stateIcon effective'></i>有效</span>`
      break
    case false:
      state = `<span><i class='stateIcon invalid'></i>无效</span>`
      break
    default:
      state = `<span>未知</span>`
  }
  return state
}

const filterStatusEdit = (data) => {
  let state = ''
  switch (data) {
    case true:
      state = `<span><i class='stateIcon effective'></i>已编辑</span>`
      break
    case false:
      state = `<span><i class='stateIcon invalid'></i>待编辑</span>`
      break
    default:
      state = `<span>未知</span>`
  }
  return state
}
/* 生命周期状态 */
const lifecycleAciton = (data) => {
  let state = ''
  switch (data) {
    case true:
      state = `<span><i class='stateIcon effective'></i>已启用</span>`
      break
    case false:
      state = `<span><i class='stateIcon refuse'></i>已禁用</span>`
      break
    default:
      state = `<span>未知</span>`
  }
  return state
}
const iconFont = (data) => {
  let icon = ''
  switch (data) {
    case 'hive_db':
    case 'rdbms_db':
      case 'database':
      icon = `<i class='iconfont iconshujuku' style='color:#F5A720'></i>`
      break
      case 'table':
        case 'rdbms_table':
      case 'hive_table':
        icon = `<i class='iconfont icona-zu4376' style='color:#277AF5'></i>`
        break
      case 'column':
      case 'rdbms_column':
      case 'hive_column':
      icon = `<i class='iconfont icona-lujing1755' style='color:#F5A720'></i>`
      break
      case 'meta_model_type_indicators':
      icon = `<i class='iconfont iconzhibiao' style='color:#8F4DF2'></i>`
      break
      case 'meta_model_type_task':
      icon = `<i class='iconfont iconrenwu' style='color:#F53D3D'></i>`
      break
      case 'meta_model_type_model':
      icon = `<i class='iconfont iconmoxing' style='color:#277AF5'></i>`
      break
      case 'meta_model_type_workflow':
      icon = `<i class='iconfont iconlujing495' style='color:#2BD84C'></i>`
      break
    default:
      icon = ''
  }
  return icon
}

/* 数据标准-上线状态*/
const filterStatusLaunch = (data) => {
  let state = ''
  switch (data) {
    case 'online':
      state = `<span><i class='stateIcon approval'></i>已发布</span>`
      break
    case 'offline':
      state = `<span><i class='stateIcon invalid'></i>未发布</span>`
      break
    case 'release_status_online':
      state = `<span><i class='stateIcon approval'></i>已发布</span>`
      break
    case 'release_status_off':
      state = `<span><i class='stateIcon invalid'></i>未发布</span>`
      break
    default:
      state = `<span><i class='stateIcon invalid'></i>未发布</span>`
  }
  return state
}

/* 数据标准发布动作*/
const publishAction = (data) => {
  let state = ''
  switch (data) {
    case 'release_status_online':
      state = `<span>上线</span>`
      break
    case 'release_status_off':
      state = `<span>下线</span>`
      break
    default:
      state = `<span>未知</span>`
  }
  return state
}
/* 审批状态 */
const approvalStatus = (data) => {
  let state = ''
  switch (data) {
    case 'change':
      state = `<span><i class='stateIcon change'></i>已变更</span>`
      break
    case 'refuse':
      state = `<span><i class='stateIcon refuse'></i>已拒绝</span>`
      break
    case 'cancel':
      state = `<span><i class='stateIcon cancel'></i>已取消</span>`
      break
    case 'approval':
      state = `<span><i class='stateIcon approval'></i>已通过</span>`
      break
    case 'apply':
      state = `<span><i class='stateIcon apply'></i>已申请</span>`
      break
    default:
      state = `<span><i class='stateIcon invalid'></i>未申请</span>`
  }
  return state
}
const standardType = (data) => {
  let state = ''
  if (data && typeof data !== 'number' && !isNaN(data)) {
    data = parseInt(data)
  }
  switch (data) {
    case 1:
      state = `<span>国家标准</span>`
      break
    case 2:
      state = `<span>企业标准</span>`
      break
    case 3:
      state = `<span>行业标准</span>`
      break
    default:
      state = `<span>--</span>`
  }
  return state
}
const ruleActionType = (data) => {
  let state = ''
  switch (data) {
    case 'delete':
      state = `<span>删除</span>`
      break
    case 'move':
      state = `<span>移动</span>`
      break
    case 'archive':
      state = `<span>归档</span>`
      break
    default:
      state = `<span>未知</span>`
  }
  return state
}
const dictFilter = (data, dictList, props) => {
  if (!data && data !== false) {
    return ''
  }
  let state = ''
  if (props) {
    state = dictList.find(item => item[props.value] === data)
    return state[props.label]
  } else {
    state = dictList.find(item => item.dictdtValue === data)
    return state ? state.dictdtName : ''
  }
}
// 元数据采集状态
const filterCollectionStatus = (data, startExecuteTime) => {
  let state = ''
  switch (data) {
    case '1':
      state = `<span><i class='stateIcon approval'></i>成功</span>`
      break
    case '0':
      state = `<span><i class='stateIcon refuse'></i>失败</span>`
      break
    default:
      state = `<span><i class='stateIcon invalid'></i>待执行</span>`
  }
  if (startExecuteTime && data === null) {
    state = `<span><i class='stateIcon apply'></i>执行中</span>`
  }
  return state
}

// 是否勾选
const filterCheck = (data) => {
  return data ? '<span class="iconfont iconcheck" style="color:#2BD84C"></span>' : '<span class="iconfont iconclose" style="color:#b7b7b7"></span>'
}

export default {
  filterStatus,
  iconFont,
  filterStatusEdit,
  filterStatusLaunch,
  standardType,
  ruleActionType,
  lifecycleAciton,
  publishAction,
  dictFilter,
  approvalStatus,
  filterCollectionStatus,
  filterCheck
}
